package org.example.meetingsystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.example.meetingsystem.entity.User;
import org.example.meetingsystem.enums.UserStatus;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    /**
     * 根据用户名查询用户
     */
    @Select("SELECT * FROM users WHERE username = #{username}")
    User selectByUsername(@Param("username") String username);

    /**
     * 查询待审核的客户
     */
    @Select("SELECT * FROM users WHERE role = 'CUSTOMER' AND status = 'PENDING'")
    List<User> selectPendingCustomers();

    /**
     * 批量更新用户状态
     */
    @Update("UPDATE users SET status = #{status} WHERE id IN (${ids})")
    int batchUpdateStatus(@Param("status") UserStatus status, @Param("ids") String ids);
}